package com.wondersgroup.fjzlpt.org.controller.view.model;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import com.quick.framework.util.QuickPrincipalUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.quick.framework.boot.web.utils.RequestUtils;
import com.wondersgroup.fjzlpt.org.service.inter.fwb.FwbService;
import com.wondersgroup.fjzlpt.org.service.inter.jtqy.JtqyService;

@Controller
@RequestMapping("model")
public class ModelController {
	
	@Autowired
	private JtqyService jtqyService;
	
	@Autowired
	private FwbService fwbService;
	
	
	@RequestMapping("/zjModel.html")
	public String zjModel(HttpServletRequest request)
	{
		Map<String, String> map = RequestUtils.GetParameterMap(request);
        String USERID = QuickPrincipalUtils.getUserID(request);
        String YLJGID = QuickPrincipalUtils.getPtjgID(request);
		map.put("PTJGID", YLJGID);
		String RS = map.remove("RS");
		String QYXXIDS = map.remove("QYXXIDS");
		String YLTDID = map.remove("YLTDID");
		String FWBIDS = map.remove("FWBIDS");
		JSONArray tdxxArr = jtqyService.queryTdxxAll(map);
		JSONObject jo = new JSONObject();
		jo.put("YTDID", YLTDID);
		jo.put("RS", RS);
		jo.put("QYXXIDS", QYXXIDS);
		jo.put("FWBIDS", FWBIDS);
		jo.put("USERID", USERID);
		jo.put("tdxxArr", tdxxArr);
		request.setAttribute("DATA", jo);
		return "common/zjModel";
	}
	
	@RequestMapping("/bgfwbModel.html")
	public String bgfwbModel(HttpServletRequest request)
	{
		Map<String, String> map = RequestUtils.GetParameterMap(request);
		String JGXZQHDM = QuickPrincipalUtils.getXzqhdm(request);
		String YLJGID = QuickPrincipalUtils.getPtjgID(request);
		map.put("YLJGID", YLJGID);
		map.put("JGXZQHDM", JGXZQHDM);
		map.put("FWBZT", "1");
		JSONArray ja =  fwbService.queryAll(map);
		String RS = map.remove("RS");
		String FWBIDS = map.remove("FWBIDS");
		String QYXXIDS = map.get("QYXXIDS");
		JSONObject jo = new JSONObject();
		jo.put("QYXXIDS", QYXXIDS);
		jo.put("FWBIDS", FWBIDS);
		jo.put("RS", RS);
		jo.put("rows", ja);
		request.setAttribute("DATA", jo);
		return "common/bgfwbModel";
	}
	
	@RequestMapping("/xyModel.html")
	public String xyModel(HttpServletRequest request)
	{
		Map<String, String> map = RequestUtils.GetParameterMap(request);
		String YLJGID = QuickPrincipalUtils.getPtjgID(request);
		map.put("YLJGID", YLJGID);
		String RS = map.remove("RS");
		String QYXXIDS = map.remove("QYXXIDS");
		String TDID = map.remove("TDID");
		String FWBIDS = map.remove("FWBIDS");
		JSONObject jo = jtqyService.queryNormalTdxx(map);
		jo.put("YTDID", TDID);
		jo.put("RS", RS);
		jo.put("QYXXIDS", QYXXIDS);
		jo.put("FWBIDS", FWBIDS);
		request.setAttribute("DATA", jo);
		return "common/xyModel";
	}
	
	@RequestMapping("/lsjlModel.html")
	public String lsjlModel(HttpServletRequest request)
	{
		Map<String, String> map = RequestUtils.GetParameterMap(request);
		JSONObject jo = jtqyService.findLsjlAll(map);
		request.setAttribute("DATA", jo);
		return "common/lsjlModel";
	}

}
